<template>
    <div class="box">
        <van-nav-bar title="详情" />
        <van-tabs v-model:active="active">
            <van-tab title="商品">
                <lunbo :list="del.pics"></lunbo>
                <p>{{ del.goods_name }}</p>
                <p style="color: red;">${{ del.goods_price }}</p>
            </van-tab>
            <van-tab title="详情">
                <div v-html="del.goods_introduce"></div>
            </van-tab>
            <van-tab title="评价">内容 3</van-tab>
        </van-tabs>

        <van-action-bar>
            <van-action-bar-icon icon="chat-o" text="客服" dot />
            <van-action-bar-icon icon="cart-o" text="购物车" badge="5" />
            <van-action-bar-icon icon="shop-o" text="店铺" badge="12" />
            <van-action-bar-button type="warning" text="加入购物车" @click="addFun()"/>
            <van-action-bar-button type="danger" text="立即购买" />
        </van-action-bar>

    </div>
</template>

<script setup>
import { ref } from 'vue'
const active = ref(0);
import { useRoute, useRouter } from 'vue-router'
const router = useRouter()
const route = useRoute()
let goods_id = ref(route.query.goods_id)
import { detailApi } from '@/api/api'
import lunbo from '@/components/lunbo.vue';
let del = ref("")
const delFun = () => {
    detailApi(goods_id.value).then(res => {
        del.value = res.data.message
    })
}
delFun()
import { showToast } from 'vant';
import { useCounterStore } from '@/stores/counter'
// 在组件内部的任何地方均可以访问变量 `store` ✨
const store = useCounterStore()
const addFun=()=>{
    store.addshopCar(del.value)
    router.push("/home/shop")
    showToast('加入成功');
}
</script>

<style lang="scss" scoped></style>